package com.hu.zhcc.shiro.service.dingming;

import com.hu.zhcc.common.entity.Page;
import com.hu.zhcc.common.entity.PageRequest;
import com.hu.zhcc.shiro.dao.dingming.THealthPlanMapper;
import com.hu.zhcc.shiro.entity.dingming.THealthPlan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class THealthPlanServiceImpl implements THealthPlanService{
    @Autowired
    private THealthPlanMapper tHealthPlanMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return tHealthPlanMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(THealthPlan record) {
        return tHealthPlanMapper.insert(record);
    }

    @Override
    public int insertSelective(THealthPlan record) {
        return tHealthPlanMapper.insertSelective(record);
    }

    @Override
    public THealthPlan selectByPrimaryKey(Integer id) {
        return tHealthPlanMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(THealthPlan record) {
        return tHealthPlanMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(THealthPlan record) {
        return tHealthPlanMapper.updateByPrimaryKey(record);
    }

    @Override
    public Page<THealthPlan> listTHealthPlan (Map<String, Object> parameters, int offset, int limit) {
        int total = tHealthPlanMapper.countHealthPlan(parameters);
        List<THealthPlan> tHealthPlans= null;
        if (total > 0) {
            PageRequest pageRequest = new PageRequest(offset, limit, parameters);
            tHealthPlans = tHealthPlanMapper.listHealthPlan(pageRequest);
        }
        return new Page<THealthPlan>(total, tHealthPlans);
    }
}
